#include <cstdio>
#include <cassert>
#include "sistema.h"

const float PI = 3.14;

const float _IEXC_NOM = 88.0;
const float _PT_NOM = 9550000;
const float _SIM_TSTEP = 0.00005;
const int _STEPS_PER_SIM = 800;

using namespace std;

int main() {
    sistema ms;
    matmem m;

    m.init();

    ms.setA(300);
    ms.setD((float)0.08);
    ms.setIEXC(_IEXC_NOM);
    ms.setV(3688);
    ms.setWS(2*PI*60);
    ms.setPT(_PT_NOM);
    ms.setXS((float)1.105);
    ms.setH(2);

    ms.setRPS();
    ms.setTSTEP(_SIM_TSTEP);

    ms.init(0);

    for (unsigned i = 0;i < 10000;++i) {
        ms.go(_STEPS_PER_SIM);
        printf("%.6f\n", ms.fi);
    }
    return 0;
}
/*
        ms.go(cmd_steppsim);
        estator.setphase(-r2d(ms.fi));
        tempi=ms.I.abs();
        tempe=ms.e.abs();

        estator.setampl(15*tempi/1000);
        rotor.setampl(15*tempe/(1000*ms.xs));
        rotor.setphase(r2d(ms.delta+3.1415/2));
        calcres(&estator, &rotor, &m, &p);
        resul.setampl((float)m);
        resul.setphase(p);

        grafdelta.addpoint(ms.ttotal, r2d(ms.delta));
        grafcosfi.addpoint(ms.ttotal, cos(ms.fi));
        grafi.addpoint(ms.ttotal, tempi);
        grafwr.addpoint(ms.ttotal, ms.wr*60/(2*pi()));
        grafpt.addpoint(ms.ttotal, ms.pt/SBASE);
        grafe.addpoint(ms.ttotal, tempe);
        grafs.addpoint(ms.ttotal, ms.s.abs()/SBASE);
        grafq.addpoint(ms.ttotal, ms.q/SBASE);
        grafp.addpoint(ms.ttotal, ms.p/SBASE);
*/
